#!/bin/sh
# shellcheck disable=SC2039
# shellcheck disable=SC2046
# shellcheck disable=SC2006

set -e
BasePath=$(cd `dirname "$0"`; pwd)

builddir="$BasePath/build"
rm -rf "$builddir"
mkdir -p "$builddir"



OSLIST="windows linux freebsd"
for os in $OSLIST; do

    suffix=""
    if [ "windows" = "$os" ]; then
        suffix=".exe"
    fi
    echo "build for $os"

    targetdir="$builddir/$os"
    mkdir -p "$targetdir"

    # build acl-proxy
    echo -e "\tbuild acl-proxy"
    cd "$BasePath/acl-proxy"
    obj="acl-proxy$suffix"
    dir="$targetdir/acl-proxy"
    mkdir "$dir"
    GOOS="$os" GOARCH=amd64 go build -o "$obj"
    mv "$obj" "$dir/"
    cp "config.json" "$dir/"



done

